var app={
	single_chat:function(){//单聊
		$$.openWin({
	        url: "../singleChat/singleChat.html",
	        id: "singleChat.html"
	   });
	},
	group_chat:function(){//群聊
		$$.openWin({
	        url: "../groupChat/groupChat.html",
	        id: "groupChat.html"
	   });
	},
	msg_info:function(){//岗位消息
	    $$.openWin({
	        url: "../postInfo/postInfo.html",
	        id: "postInfo.html",
	        extras: {}// 自定义扩展参数
	    });
	},
	msg_sign:function(){//补签消息
        $$.openWin({
            url: "../signInfo/signInfo.html",
            id: "signInfo.html"
        })
	},
	long_down_common:function(){//长按：岗位消息、补签消息、岗位问答
		mui("#msg_content_div").on("longtap",".alert_operation",function(event){
			var _this = this;
			var uid = this.getAttribute('data-uid');
		    console.log("存放id = " + uid);
		    
		    var btnArray = [{
		        title: "置顶"
		    }];
		    plus.nativeUI.actionSheet({
		        title: "选择操作",
		        cancel: "取消",
		        buttons: btnArray
		    }, function(e) {
		        var index = e.index;
		        console.log(index);
		        
		        switch(index){
		            case 1://置顶
						cloneTop(_this);
		                break;
		        }
		    });
		});
	},
	long_down_chat:function(){//长按：群聊、单聊
		mui('#msg_content_div').on("longtap",".alert_operation_chat",function(){
			var _this = this;
			var uid = this.getAttribute('data-uid');
		    console.log(uid);
		
		    var btnArray = [{
		        title: "置顶"
		    }, {
		        title: "加入黑名单"
		    }, {
		        title: "删除聊天"
		    }];
		    plus.nativeUI.actionSheet({
		        title: "选择操作",
		        cancel: "取消",
		        buttons: btnArray
		    }, function(e) {
		        var index = e.index;
		        switch(index){
		            case 1://置顶
						cloneTop(_this);
		                break;
		            case 2://加入黑名单
		            	alert("加入黑名单");
						
		                break;
		            case 3://删除聊天
						_this.parentNode.removeChild(_this);				
		                break;
		        }
		    });
		});
	},
	msgNumber:function(number){//显示消息数量
		var html = "";
		if(number > 0){
			html =  '<p class="mui-ellipsis">'+
		                '<span class="mui-badge mui-badge-primary">'+number+'</span>'+
		            '</p>';
		}
        return html;
	}
}






/**
 * 通用置顶
 * @param {Object} _this
 */
function cloneTop(_this){
	//复制节点
	var cloneEm = _this.outerHTML;
	//删除节点
	_this.parentNode.removeChild(_this);
	//将克隆的节点加入第一位
//	mui("#msg_content")[0].insertAdjacentHTML("afterbegin",cloneEm);
	mui("#msg_content_div")[0].insertAdjacentHTML("afterbegin",cloneEm);
	
	//移除mui-active
//	mui("#msg_content a")[0].classList.remove("mui-active");
}


